<?php
class Zend_Controller_Action_Helper_Express extends Zend_Controller_Action_Helper_Abstract{
	
	private $realWeight=0;
	
	private $expressRate=false;
	
	public function getWeight(){
		
		return $this->realWeight;
		
	}
	
	public function calculate($volume,$weight,$locationid,$carrierid){
		
		$express=new CExpress('international');
		
		$express->setTo($locationid);
		
		$express->setVolume($volume);
		
		$express->setWeight($weight);
		
		$express->setCurrency('usd');
		
		$express->setType('0');
		
		$express->setCarrier($carrierid);
		
		$view=$this->getActionController()->view;
		
		$interExpressArray=$express->searchInternational();
		
		$this->realWeight=$express->get_weight();
		
		$domesticShippingPrice=$view->domesticTotal($this->realWeight,0,0,$this->expressRate);
		
		$shippingPrice=$domesticShippingPrice+
									   $view->expressTotal($this->realWeight,$interExpressArray[0]['first_weight'],$interExpressArray[0]['addition_weight'],$interExpressArray[0]['fuel_surcharge'],$interExpressArray[0]['price'],$this->expressRate);
		
		return $shippingPrice;
									   
	}
	
	public function getExpressArray($volume,$weight,$locationid){
		
		$express=new CExpress('international');
		
		$express->setTo($locationid);
		
		$express->setVolume($volume);
		
		$express->setWeight($weight);
		
		$express->setCurrency('usd');
		
		$express->setType('0');
		
		$interExpressArray=$express->searchInternational();
		
		$this->realWeight=$express->get_weight();
		
		return $interExpressArray;
		
	}
	
}
